﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    [FontTag]
    public class DefineFont4Tag : Tag
    {
        public ushort FontID
        {
            get;
            protected set;
        }

        public Boolean FontFlagsHasFontData
        {
            get;
            protected set;
        }


        public Boolean FontFlagsItalic
        {
            get;
            protected set;
        }

        public Boolean FontFlagsBold
        {
            get;
            protected set;
        }

        public StringRecord FontName
        {
            get;
            protected set;
        }

        public Byte[] FontData
        {
            get;
            protected set;
        }

        public DefineFont4Tag(int len, int offset)
            : base(TagCodes.DefineFont4, len, offset)
        {

        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            FontID = reader.ReadUInt16();

            reader.SkipBits(5);

            FontFlagsHasFontData = reader.ReadBoolean();
            FontFlagsItalic = reader.ReadBoolean();
            FontFlagsBold = reader.ReadBoolean();

            reader.AlignBits();

            FontName = new StringRecord(10);
            FontName.SwfDeserialize(reader);

            int fontDataLength = TagLength - ((int)reader.Position - TagOffset);
            FontData = new Byte[fontDataLength];
            reader.Read(FontData, 0, fontDataLength);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
